<template>
  <div class="searchbox">
    <!--  -->
    <el-input
      v-if="typeof value !== 'undefined'"
      placeholder="请输入内容"
      :value="value"
      class="input"
      @input="(val) => $emit('input', val)"
    >
      <el-button
        slot="append"
        icon="el-icon-search"
        :loading="loading"
        @click="$emit('search')"
      ></el-button>
    </el-input>
    <!-- 添加用户 -->
    <el-button type="primary" @click="$emit('click')" v-if="$slots.default">
      <slot></slot>
    </el-button>
  </div>
</template>

<script>
export default {
  name: "Search",
  props: {
    /**
     * 输入搜索词
     */
    value: String,
    /**
     * 搜索loading
     */
    loading: Boolean,
  },
};
</script>

<style lang = "scss" scoped>
.searchbox {
  display: flex;
  margin-bottom: 15px;
  .input {
    width: 368px;
    margin-right: 15px;
  }
}
</style>